<?php

use think\migration\Migrator;

class ExtensionEavEntityType extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     */
    public function change(): void
    {
        $table = $this->table('extension_eav_entity_type', ['engine' => 'InnoDB', 'comment' => '实体类型表（如商品/用户等）']);
        $table->addColumn('entity_type_code', 'string', ['limit' => 50, 'comment' => '实体类型编码'])
            ->addColumn('entity_table', 'string', ['limit' => 64, 'comment' => '实体主表名'])
            ->addIndex(['entity_type_code'], ['name' => 'entity_type_code', 'unique' => true])
            ->addTimestamps()
            ->addSoftDelete()
            ->create();
    }
}
